package org.ezplatform.office.rd.ldbb.web.rest;

import io.swagger.annotations.ApiOperation;
import org.ezplatform.core.common.WebUser;
import org.ezplatform.core.web.util.WebUtils;
import org.ezplatform.office.rd.ldbb.service.LdbbService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @author gaoyw
 * @date 2024年08月08日 9:10
 *
 * 领导补办列表
 */
@RestController
@RequestMapping({"/api/w/rd/ldbb"})
public class LdbbController {
    public static final Logger LOG = LoggerFactory.getLogger(LdbbController.class);
    @Resource
    private JdbcTemplate jdbcTemplate;
    @Autowired
    private LdbbService ldbbService;
    //20240808gaoyw领导公文补办列表
    @ApiOperation(value = "领导公文补办列表", notes = "领导公文补办列表")
    @GetMapping({"/getLdbbData"})
    public Page<Map> getLdbbSwData(HttpServletRequest request) {
        WebUser user= WebUtils.getCurrentUser();
        String leaderId = user.getUserId();
        String wjbt = request.getParameter("wjbt");
        return  this.ldbbService.getLdbbData(request,leaderId,wjbt);
    }

    //20240808gaoyw领导补办完成后在ldbbwjids将领导的这条数据得补办状态改成2
    @ApiOperation(value = "领导补办完成后在ldbbwjids将领导的这条数据得补办状态改成2", notes = "领导补办完成后在ldbbwjids将领导的这条数据得补办状态改成2")
    @GetMapping({"/updateDate"})
    public void updateDate(String businesskey) {
        WebUser user = WebUtils.getCurrentUser();
        String leaderId = user.getUserId();
        String sql="update ldbbwjids set bbzt='2' where ldyhid='"+leaderId+"' and gwdataid='"+businesskey+"' ";
        jdbcTemplate.update(sql);
    }
}
